/*
 * cars_messaging.c
 *
 *  Created on: 13 Dec 2011
 *      Author: marco
 */

#include "cars_messaging.h"

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>

int newMessage(char t, char *payload, message_t* m, int dim){

	m->type = t;
	if (payload == NULL){
		m->length = 0;
		return(0);
	}

	m->buffer = payload;
	m->length = dim;

	return (m->length);
}

void deleteMessage(message_t *m) {
	if(!m)
		return;
	if(!m->buffer){
		free(m->buffer);
	}
	free(m);

	return;
}
